﻿function btnWenZi() {
    showTool();
    var tools = getTools();

    var html = "";

    html += "<div class='d_z adtitle clearfix'><div class='adfl dw30'>插入文字</div><div class='adfr adfwn dw60 adtar'><span class='d_z adbtn adbgcred' data-f='webziqueding()'>确定</span><span class='d_z adbtn ' data-f='webzifanhui()'>返回</span></div></div>";


    html += "<textarea class='d_z adtextarea adfs18' placeholder='请输入需要插入的文字信息'></textarea></br>";
    html += "<span class='d_z adbtn' data-f='webziyangshi()'>样式</span>";
    html += "<span class='d_z adbtn' data-f='webziqingkong()'>清空</span></br>";

    html += "<div class='d_z d_z1 adbtnwz'><span class='d_z '>文字大小</span><br/>";
    html += "<span class='d_z adbtn  wzdx' v='24px' data-f='webzistyle(\"wzdx\",\"font-size\",\"24px\")'>最大</span>";
    html += "<span class='d_z adbtn  wzdx' v='18px' data-f='webzistyle(\"wzdx\",\"font-size\",\"18px\")'>正常</span>";
    html += "<span class='d_z adbtn  wzdx' v='14px' data-f='webzistyle(\"wzdx\",\"font-size\",\"14px\")'>最小</span></br>";

    html += "<span class='d_z '>文字对齐</span><br/>";

    html += "<span class='d_z adbtn  wzdq' v='left' data-f='webzistyle(\"wzdq\",\"text-align\",\"left\")'>左对齐</span>";
    html += "<span class='d_z adbtn  wzdq' v='center' data-f='webzistyle(\"wzdq\",\"text-align\",\"center\")'>居中</span>";
    html += "<span class='d_z adbtn  wzdq' v='right' data-f='webzistyle(\"wzdq\",\"text-align\",\"right\")'>右对齐</span></br>";

    html += "<span class='d_z '>文字颜色</span><br/>";
    var color = "000000,FF0000,00FF00,0000FF,FF00FF,00DB00,F9F900,984B4B,9F4D95,00CACA,0000C6,5B00AE";
    $(color.split(',')).each(function (k,v) {
        html += "<span class='d_z adbtn  wzys' v='#"+v+"' data-f='webzistyle(\"wzys\",\"color\",\"#" + v + "\")' style='background-color:#" + v + "'>#" + v + "</span>";
    });

    html+="</div>";

    tools.html(html);
    bindButtonClickEvent();

    //loadwenzistyle();
}

function webzistyle(lb,k,v) {
    var content = getContent();
    content.css(k,v);

    //选择状态
    $("."+lb).removeClass("adbtnS");
    showlog(v);
    $("."+lb+"[v='"+v+"']").addClass("adbtnS");
}

function webzifanhui() {
    getMenu().show();
    getTools().hide();
}

function webziqingkong() {
    var content = getContent();
    content.val("");
}

function webziyangshi() {
    if ($(".adbtnwz").length > 0)
        $(".d_z1").removeClass("adbtnwz");
    else
        $(".d_z1").addClass("adbtnwz");
}

function webziqueding() {
    getMenu().hide();
    getTools().hide();

    removeBgColor();

    var content = getContent();
    var text = content.val();

    var span = G_CLICKELEMENT.clone(true);
    if (G_CLICKELEMENT[0].tagName == "IMG")
        span = $("<div></div>");

    span.css("font-size", content.css("font-size"));
    span.css("text-align", content.css("text-align"));
    span.css("color", content.css("color"));
    span.css("display","block");


    span.empty();
    //加一个换行
    span.html(text + "</br>");

    //插入内容
    G_CLICKELEMENT.before(span);
    bindElementClickEvent(span, elementClickEvent);
}
